<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="resources/js/jquery-3.4.1.min.js"></script>
<title>Insert title here</title>
</head>
<body>

<script type="text/javascript">
    $(function(){
        //alert(1);
        //这是json格式，但不是json串，这是key:value，相当于一个map。{}外面得加上一个单引号才是串，但只是个json格式的字符串，不是json数据
        var params = '{"id":1,"account":"zaey","password":"1997","authType":1}';
 
        /*$.post(url,params,function(data){//这是回调json字符串，不能发送json字符串
 
        },"json");*/
 
        $.ajax({
            url: "${pageContext.request.contextPath }/testJson.action",
            data: params,
            contentType: "application/json;charset=UTF-8", //发送数据的格式
            type: "post",
            dataType: "json", //这是返回来是json，也就是回调json
            success: function(data){
                alert(data.account);
            }
        });
    });
</script>
</body>
</html>